/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-26
 * Time: 11:15
 */
public class myPow {
    public double myPow(double x, int n) {
        if (n>0){
            return pow(x,n);
        }else {
            return pow(x,-n);
        }
    }
    public double pow(double x,int n){
        if (n==0){
            return 1;
        }
        double tmp= pow(x,n/2);
        if (n%2==0){
            return tmp*tmp;
        }else {
            return tmp*tmp*x;
        }
    }
}
